
/*
 * Copyright (c) 2013.
 * 游戏服务器核心代码编写人陈磊拥有使用权
 * 联系方式：E-mail:13638363871@163.com ;qq:502959937
 * 个人博客主页：http://my.oschina.net/chenleijava
 */

package com.dc.gameserver.serverCore.controller.handleController;

import com.dc.gameserver.proto.gameserverprotoVo.notifyAccpetPKRequest;
import com.dc.gameserver.proto.gameserverprotoVo.notifyAccpetPKResponse;
import com.dc.gameserver.serverCore.controller.AbstractController.AbstractController;
import com.dc.gameserver.serverCore.controller.AbstractController.IController;
import com.dc.gameserver.serverCore.service.character.PlayerInstance;
import com.dc.gameserver.serverCore.service.managerService.PlayerManagerService;
import com.google.protobuf.MessageLite;
import org.springframework.stereotype.Service;

/**
 * @author : 石头哥哥
 *         Project : LandlordsServer
 *         Date: 13-6-4
 *         Time: 上午11:49
 *         Connect: 13638363871@163.com
 *         packageName: Server.ServerCore.Controller
 *         服务器转发pk请求
 */
@Service
public class notifyAccpetPkController extends AbstractController {

    /**ID**/

    /**
     */
    @Override
    public void PostConstruct() {
        int ID= notifyAccpetPKRequest.msgID.ID_VALUE;
       GAME_CONTROLLERS[ID]=this;   //业务逻辑处理引用
       IController.MESSAGE_LITE[ID]=  notifyAccpetPKRequest.getDefaultInstance();
    }

     /**
     * messageLite数据结构体分发
     *
     * @param messageLite
     * @param player
     * @throws Exception
      * this logic  will be callBack {@link com.dc.gameserver.serverCore.controller.handleController.pvpCoreController.battleReadyController# DispatchMessageLit(com.google.protobuf.MessageLite, com.dc.gameserver.serverCore.model.player.PlayerInstance)}  }
     */

    @Override
    public void DispatchMessageLit(MessageLite messageLite, PlayerInstance player) throws Exception {
        notifyAccpetPKRequest notifyAccpetPKRequest= (notifyAccpetPKRequest) messageLite;
        int notifyPlayerID=notifyAccpetPKRequest.getPlayerID();
        PlayerInstance pkPlayer= PlayerManagerService.INTEGER_PLAYER_INSTANCE_MAP.get(notifyPlayerID);
        notifyAccpetPKRequest=null;
        notifyAccpetPKResponse.Builder builder= notifyAccpetPKResponse.newBuilder();
        builder.setPlayerID(player.getID());  //发起挑战的玩家编号
        pkPlayer.DirectSend(wrappedBufferShort(notifyAccpetPKResponse.msgID.ID_VALUE,builder.build()));
    }
}
